﻿using System;
using Domain.Entity;

namespace Domain
{
    public static class CustomsLog
    {
        /// <summary>
        /// 写异常日志
        /// </summary>
        /// <param name="error"></param>
        /// <param name="detail"></param>
        public static void WriteExceptionErrorLog(string error,Exception detail,string remark=null)
        {
            try
            {
                using (var db = new DBDataContext())
                {
                    ErrorLog log=new ErrorLog();
                    log.DateTime = DateTime.Now;
                    log.Info = error;
                    log.Detail = detail.ToString()+remark;
                    db.ErrorLog.InsertOnSubmit(log);
                    db.SubmitChanges();
                }
               
            }
            catch (Exception)
            {
                
            }
        }

        public static void WriteInfoLog(string info, string detail)
        {
            try
            {
                using (var db = new DBDataContext())
                {
                    ErrorLog log = new ErrorLog();
                    log.DateTime = DateTime.Now;
                    log.Info = info;
                    log.Detail = detail;
                    db.ErrorLog.InsertOnSubmit(log);
                    db.SubmitChanges();
                }

            }
            catch (Exception)
            {

            }
        }
    }
}
